/*
 * Created by IntelliJ IDEA.
 * User: zslajchrt
 * Date: Feb 23, 2011
 * Time: 7:23:53 PM
 */
package chloroform.l10n

import java.util.Locale
import chloroform.ProjectEntry
import scaladuct.l10n.{SafeMetaData, CommonMetaData}
import java.lang.String
import util.Deopt._

trait ProjectMetaData {
  def projectMeta: Option[CommonMetaData]

  def projectEntryMeta(entry: ProjectEntry): Option[CommonMetaData]
}

trait ProjectMetaDataSource {
  def projectMetaData(locale: Locale): Option[ProjectMetaData]
}

class ProjectEntrySafeMetaData(metaSource: ProjectMetaDataSource, entry: ProjectEntry, defaultTitle: String,
                               locale: Locale) extends CommonMetaData {
  def icon =
    Some(deopt(
      deopt(
        deopt(
          metaSource.projectMetaData(locale)).projectEntryMeta(entry)).icon, null))

  def description =
    Some(deopt(
      deopt(
        deopt(
          metaSource.projectMetaData(locale)).projectEntryMeta(entry)).description, ""))


  def title =
    Some(deopt(
      deopt(
        deopt(
          metaSource.projectMetaData(locale)).projectEntryMeta(entry)).title, defaultTitle))
}